package org.example.bigdata.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.example.bigdata.entity.Hotspots;
import org.example.bigdata.entity.Post;
import org.example.bigdata.service.HotspotsService;
import org.example.bigdata.mapper.HotspotsMapper;
import org.example.bigdata.service.PostService;
import org.example.bigdata.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
* @author Jmx
* @description 针对表【hotspots】的数据库操作Service实现
* @createDate 2024-05-05 10:44:52
*/
@Service
@Slf4j
public class HotspotsServiceImpl extends ServiceImpl<HotspotsMapper, Hotspots>
    implements HotspotsService{

    @Autowired
    private PostService postService;

    @Override
    public Result fetchHotSpots(String token) {
        List<Hotspots> list = query().list();
        return Result.success(list);
    }

    @Override
    public Result fetchDetails(int id) {
        QueryWrapper<Post> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("hotSpot_id",id);
        List<Post> list = postService.list(queryWrapper);
        return Result.success(list);
    }
}




